package com.bloveoacom.base;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.support.multidex.MultiDex;
import android.view.Gravity;

import com.blankj.utilcode.util.ToastUtils;
import com.blankj.utilcode.util.Utils;
import com.bloveoacom.util.ActivityLifecycle;
import com.bloveoacom.util.ActivityUtil;
import com.bloveoacom.util.ToastUtil;
import com.bloveoacom.weichi.activity.LoginActivity;
import com.mob.MobSDK;
import com.tencent.bugly.crashreport.CrashReport;


/**
 * Created by yujunlong on 2016/12/6.
 */

public class AppContext extends Application {
    private static AppContext instance;

    public static Handler mHandler = new Handler();




    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
              // default 0

        Utils.init(this);
        ToastUtils.setGravity(Gravity.CENTER,0,0);
        UserInfoBean.getInstance().getAccess();

        CrashReport.initCrashReport(getApplicationContext(), "72ac0a8ca4", true);

        MobSDK.init(this);
//        String umengAppkey = "5b55dc45b27b0a02080001ae";
//        UMConfigure.init(this, umengAppkey, "bloveoa", UMConfigure.DEVICE_TYPE_PHONE, "");
        registerActivityLifecycleCallbacks(new ActivityLifecycle());
    }

    public static void exit(Context context){
        UserInfoBean.getInstance().clearUserInfo();
        ActivityUtil.startActivity(context, LoginActivity.class);
        //JPushUtils.clearBieMing();
        // AppManager.getAppManager().finishAllActivity();
        //JPushInterface.clearAllNotifications(context);
        //Intent intent = new Intent(context, MainActivity.class);
        //context.startActivity(intent);
    }
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    public static AppContext context() {
        return instance;
    }

}
